package com.neuedu.his.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.neuedu.his.po.*;
import com.neuedu.his.service.MedicalrecordService;
import com.neuedu.his.service.RegisterService;
import com.neuedu.his.service.RegistlevelService;
import com.neuedu.his.service.SettlecategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/medicalrecord")
public class MedicalRecordController {
    @Autowired
    MedicalrecordService service;

    @RequestMapping("/add")
    public Boolean add(@RequestBody Medicalrecord r){
        System.out.println(r);
        return service.saveOrUpdate(r);
    }

    @RequestMapping("/list")
    public List<Medicalrecord> list(){
        return service.list();
    }

    @RequestMapping("/search")
    public Medicalrecord search(@RequestBody Map<String, String> params){
        String casenumber = params.get("casenumber");
        QueryWrapper<Medicalrecord> qw = new QueryWrapper<>();
        qw.eq("casenumber",casenumber);
        List <Medicalrecord> list = service.list(qw);
        if(list==null || list.isEmpty()){
            return new Medicalrecord();
        }else {
            return list.get(0);
        }
    }
}
